﻿using DevExpress.XtraGrid.Demos.util;
using DiaoPaiDaYin;
using Luna小店.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Luna小店.DTO
{
    public class DTO款式配置设计点数据清洗 {
        public String id { get; set; }
        public String STYLEID { get; set; }
        public String STYLE_NAME_CN { get; set; }
        public String P_ITEM_CD { get; set; }
        public String P_ITEM_VALUE { get; set; }
        public String P_ITEM_NAME_CN { get; set; }
        public String DEFAULT_CD { get; set; }
        public String DEFAULT_VALUE { get; set; }
        public String DEFAULT_NAME_CN { get; set; }
        public List<DTO款式配置设计点明细> DTO款式配置设计点明细 { get => DTO款式配置设计点明细s; set => DTO款式配置设计点明细s = value; }

        private List<DTO款式配置设计点明细> DTO款式配置设计点明细s = new List<DTO款式配置设计点明细>();

        public DTO款式配置设计点数据清洗(DTO款式配置设计点展现 dto)
        {
            this.id = dto.id;
            this.STYLEID = dto.STYLEID;
            this.STYLE_NAME_CN = dto.STYLE_NAME_CN;
            this.P_ITEM_CD = dto.P_ITEM_CD;
            this.P_ITEM_VALUE = dto.P_ITEM_VALUE;
            this.P_ITEM_NAME_CN = dto.P_ITEM_NAME_CN;
            this.DEFAULT_CD = dto.DEFAULT_CD;
            this.DEFAULT_VALUE = dto.DEFAULT_VALUE;
            this.DEFAULT_NAME_CN = dto.DEFAULT_NAME_CN;
            this.DTO款式配置设计点明细.Add(new DTO.DTO款式配置设计点明细(dto.C_ITEM_VALUE, dto.C_ITEM_NAME_CN, dto.PICURL, dto.PICN, dto.PIC));
        }
        public DTO款式配置设计点数据清洗 build设计点明细(DTO款式配置设计点展现 dto)
        {
            if (!String.IsNullOrEmpty(dto.DEFAULT_CD) || !String.IsNullOrEmpty(dto.DEFAULT_VALUE) || !String.IsNullOrEmpty(dto.DEFAULT_NAME_CN))
            {
                this.DEFAULT_CD = dto.DEFAULT_CD;
                this.DEFAULT_VALUE = dto.DEFAULT_VALUE;
                this.DEFAULT_NAME_CN = dto.DEFAULT_NAME_CN;
            }
            this.DTO款式配置设计点明细.Add(new DTO.DTO款式配置设计点明细(dto.C_ITEM_VALUE, dto.C_ITEM_NAME_CN, dto.PICURL, dto.PICN, dto.PIC));
            return this;
        }
    }

    public class DTO款式配置设计点明细
    {
        public String C_ITEM_VALUE { get; set; }
        public String C_ITEM_NAME_CN { get; set; }
        public String PICURL { get; set; }
        public String PICN { get; set; }
        public Image PIC { get; set; }
        public DTO款式配置设计点明细(String C_ITEM_VALUE,String C_ITEM_NAME_CN,String PICURL,String PICN, Image PIC)
        {
            this.C_ITEM_NAME_CN = C_ITEM_NAME_CN;
            this.C_ITEM_VALUE = C_ITEM_VALUE;
            this.PIC = PIC;
            this.PICN = PICN;
            this.PICURL = PICURL;
        }
    }

    public class DTO款式配置设计点展现 : IComparable<DTO款式配置设计点展现>
    {
        public String id { get; set; }
        public String idd { get; set; }
        public String STYLEID { get; set; }
        public String STYLE_NAME_CN { get; set; }
        public String P_ITEM_CD { get; set; }
        public String P_ITEM_VALUE { get; set; }
        public String P_ITEM_NAME_CN { get; set; }
        public String DEFAULT_CD { get; set; }
        public String DEFAULT_VALUE { get; set; }
        public String DEFAULT_NAME_CN { get; set; }
        public String C_ITEM_VALUE { get; set; }
        public String C_ITEM_NAME_CN { get; set; }
        public String PICURL { get; set; }
        public String PICN { get; set; }
        public Image PIC { get; set; }

        public DTO款式配置设计点展现(DataRow dr)
        {
            this.id = dr["id"].ToString();
            this.idd = dr["idd"].ToString();
            this.STYLEID = dr["STYLEID"].ToString();
            this.STYLE_NAME_CN = dr["STYLE_NAME_CN"].ToString();
            this.P_ITEM_CD = dr["P_ITEM_CD"].ToString();
            this.P_ITEM_VALUE = dr["P_ITEM_VALUE"].ToString();
            this.P_ITEM_NAME_CN = dr["P_ITEM_NAME_CN"].ToString();
            this.DEFAULT_CD = dr["DEFAULT_CD"].ToString();
            this.DEFAULT_VALUE = dr["DEFAULT_VALUE"].ToString();
            this.DEFAULT_NAME_CN = dr["DEFAULT_NAME_CN"].ToString();
            this.C_ITEM_VALUE = dr["C_ITEM_VALUE"].ToString();
            this.C_ITEM_NAME_CN = dr["C_ITEM_NAME_CN"].ToString();
            this.PICURL = dr["PICURL"].ToString();
            this.PICN = dr["PICN"].ToString();
            try
            {
                this.PIC = Image.FromFile(@"pic\" + PICN);
            }
            catch (Exception)
            {
                this.PIC = FunctionHelper.getSSHIRT();
            }
        }

        public DTO款式配置设计点展现(String STYLEID, String P_ITEM_VALUE,String P_ITEM_NAME_CN,String C_ITEM_VALUE,String C_ITEM_NAME_CN,String DEFAULT_FLAG)
        {
            this.STYLEID = STYLEID;
            this.P_ITEM_VALUE = P_ITEM_VALUE;
            this.P_ITEM_NAME_CN = P_ITEM_NAME_CN;
            this.C_ITEM_VALUE = C_ITEM_VALUE;
            this.C_ITEM_NAME_CN = C_ITEM_NAME_CN;
            if (DEFAULT_FLAG != "否")
            {
                this.DEFAULT_CD = P_ITEM_VALUE;
                this.DEFAULT_VALUE = C_ITEM_VALUE;
            }
        }
        public DTO款式配置设计点展现(设计点Excel格式 dto,String styleid,String stylename)
        {
            this.STYLEID = styleid;
            this.STYLE_NAME_CN = stylename;
            this.P_ITEM_VALUE = dto.设计点类型编码;
            this.P_ITEM_NAME_CN = dto.设计点类型;
            this.C_ITEM_VALUE = dto.设计点编码;
            this.C_ITEM_NAME_CN = dto.设计点;
            if (dto.是否默认 != String.Empty)
            {
                this.DEFAULT_CD = this.P_ITEM_VALUE;
                this.DEFAULT_VALUE = this.C_ITEM_VALUE;
                this.DEFAULT_NAME_CN = this.C_ITEM_NAME_CN;
            }
        }
        public int CompareTo(DTO款式配置设计点展现 other)
        {
            if (this.P_ITEM_VALUE != other.P_ITEM_VALUE)
                return 1;
            else if (this.P_ITEM_VALUE == other.P_ITEM_VALUE)
                return 0;
            else
                return -1;
        }
    }
    public class 设计点Excel格式
    {
        public String 设计点类型编码 { get; set; }
        public String 设计点类型 { get; set; }
        public String 设计点编码 { get; set; }
        public String 设计点 { get; set; }
        public String 是否默认 { get; set; }
        public 设计点Excel格式(DataRow dr)
        {
            this.设计点类型编码 = dr["设计点类型编码"].ToString().Trim();
            this.设计点类型 = dr["设计点类型"].ToString().Trim();
            this.设计点编码 = dr["设计点编码"].ToString().Trim();
            this.设计点 = dr["设计点"].ToString().Trim();
            this.是否默认 = dr["是否默认"].ToString().Trim();
        }
        public 设计点Excel格式(DTO款式配置设计点展现 dto, Boolean IfDefault)
        {
            if (IfDefault == true)
            {
                this.是否默认 = "是";
            }
            else { this.是否默认 = ""; }
            this.设计点类型编码 = dto.P_ITEM_VALUE;
            this.设计点类型 = dto.P_ITEM_NAME_CN;
            this.设计点编码 = dto.C_ITEM_VALUE;
            this.设计点 = dto.C_ITEM_NAME_CN;
        }
    }
}
